import base64 as b64
with open("D:\\Desktop\\新建文件夹\\未命名.ofd",'rb') as ofd:
    file = b64.b64encode(ofd.read()).decode('ASCII')
    with open("D:\\Desktop\\新建文件夹\\my.txt",'w') as txt:
        txt.write(file)
